<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>push_back</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ Strings</a> &gt; <a href=
    "push_back.html">push_back</a>
  </div>

  <div class="name-format">
    push_back
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string&gt;
  void push_back( const <a href=
"../containers.html">TYPE</a>&amp; val );
</pre>

  <p>The push_back() function appends <em>val</em> to the end of the
  string.</p>

  <p>For example, the following code puts 10 integers into a list:</p>
  <pre class="example-code">
   list&lt;int&gt; the_list;
   for( int i = 0; i &lt; 10; i++ )
     the_list.push_back( i );           
</pre>

  <p>When displayed, the resulting list would look like this:</p>
  <pre class="example-code">
 0 1 2 3 4 5 6 7 8 9            
</pre>

  <p>push_back() runs in <a href="../complexity.html">constant
  time</a>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    (C++ Lists) <a href="../cpplist/assign.html">assign</a><br>
    (C++ Lists) <a href="../cpplist/insert.html">insert</a><br>
    (C++ Lists) <a href="../cpplist/pop_back.html">pop_back</a><br>
    (C++ Lists) <a href="../cpplist/push_front.html">push_front</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
